<template>
  <div class="header">
    <input type="text" placeholder="添加todo..." @keyup.enter="addTodo($event.target.value)">
  </div>
</template>

<script>
export default {
  name: 'todoHeader',
  methods: {
    addTodo(value) {
      if (!value.trim()) {
        return alert('todo 不能为空 ~');
      }
      this.$emit('addTodo', value.trim());
    },
  },
};
</script>